$md: () !default;
$md: map-merge(
    (
        linkColor: #ccc,
        hrColor: #ddd,
        blockquoteBg: #f6f8fa,
        color-blockquote: #f6f8fa,
        blockquoteBorderColor: #ccc,
        markBg: yellow,
        kbdBg: #fafbfc,
        singleLineCoodeBg: #eeeeee,
        singleLineCoodeColor: #15a7a7,
        detailsBg: #fafafa,
        detailsBorderColor: #eaeaea,
        code-font: "Menlo,Monaco,Consolas,'Courier New', monospace",
        iframe-height: 40vw,
    ),
    $md
);

$color-hover-link: map-get($md, linkColor);
$color-hr: map-get($md, hrColor);
$color-blockquote-bg: map-get($md, blockquoteBg);
$color-blockquote: map-get($md, color-blockquote);
$color-blockquote-border: map-get($md, blockquoteBorderColor);
$color-mark-bg: map-get($md, markBg);
$color-kbd-bg: map-get($md, kbdBg);
$color-singlelinecode-bg: map-get($md, singleLineCoodeBg);
$color-singlelinecode: map-get($md, singleLineCoodeColor);
$color-details-bg: map-get($md, detailsBg);
$color-details-border: map-get($md, detailsBorderColor);
$font-code: map-get($md, code-font);
$height-iframe: map-get($md, iframe-height);

// tinymce5
// Markdown
#cnblogs_post_body.blogpost-body-html,
#mainContent .cnblogs-markdown {
    word-break: break-word;
    line-height: 1.75;
    font-weight: 400;
    font-size: 15px;

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        line-height: 1.5;
        margin: 35px 0 10px;
        padding: 0 0 5px 0;
    }
    h1 {
        font-size: 30px;
        margin-bottom: 5px;
    }
    h2 {
        padding-bottom: 12px;
        font-size: 24px;
        border-bottom: 1px solid $color-hr;
    }
    h3 {
        font-size: 18px;
        padding-bottom: 0;
    }
    h4 {
        font-size: 16px;
    }
    h5 {
        font-size: 15px;
    }
    h6 {
        margin-top: 5px;
    }

    p {
        margin: 22px 0;
        line-height: inherit;
    }

    img {
        display: flex;
        margin: 10px auto;
        max-width: 100% !important;
        border-radius: 4px;
    }

    hr {
        margin: 32px 0;
        border: none;
        border-bottom: 1px solid $color-hr;
    }

    code {
        font-family: $font-code;
        word-break: break-word;
        border-radius: 2px;
        overflow-x: auto;
        background-color: $color-singlelinecode-bg !important;
        color: $color-singlelinecode !important;
        font-size: 0.87em;
        padding: 0.065em 0.4em;
    }

    a {
        border-bottom: 2px solid $color-hover-link;
        background-color: transparent;
        &:hover {
            transition: box-shadow 0.2s linear;
            box-shadow: inset 0 -10px $color-hover-link;
        }
    }

    table {
        display: inline-block !important;
        font-size: 12px;
        width: auto;
        max-width: 100%;
        overflow: auto;
    }
    thead {
        background: none;
        text-align: left;
        th {
            background: none;
        }
    }
    tr:nth-child(2n) {
        background: none;
    }
    th,
    td {
        padding: 8px 4px;
        line-height: 24px;
    }
    td {
        min-width: 120px;
    }

    ol,
    ul {
        margin: 22px 0;
        padding: 0 0 0 28px;
        li {
            margin-bottom: 0;
        }
        ul,
        ol {
            margin-top: 4px;
        }
    }

    blockquote {
        margin: 22px 0;
        padding: 1px 22px;
        color: $color-blockquote;
        background: $color-blockquote-bg;
        border-left: 4px solid $color-blockquote-border;
        &::after {
            display: block;
            content: '';
        }
        & > p {
            margin: 10px 0;
        }
    }

    details {
        margin: 1.5rem 0;
        padding: 0.5rem 1rem;
        background: $color-details-bg;
        border: 1px solid $color-details-border;
        border-radius: 3px;
        & > summary {
            font-weight: 500;
            outline: none;
            cursor: pointer;
        }
    }

    iframe {
        width: 100%;
        height: $height-iframe;
        &.music {
            width: auto;
            height: auto;
        }
    }
}

// Markdown
#mainContent .cnblogs-markdown {
    kbd {
        display: inline-block;
        padding: 3px 5px;
        font: 11px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
        line-height: 10px;
        color: #444d56;
        vertical-align: middle;
        background-color: $color-kbd-bg;
        border: 1px solid #d1d5da;
        border-radius: 2px;
        box-shadow: inset 0 -1px 0 #d1d5da;
    }
    mark {
        background-color: $color-mark-bg;
    }
}

// 评论内容 Markdown
#mainContent #blog-comments-placeholder {
    blockquote,
    p {
        margin: 4px 0;
    }
}

@media screen and (max-width: 1023px) {
    iframe {
        height: 60vw;
    }
}

@media screen and (max-width: 768px) {
    h1 {
        font-size: 24px;
    }
    h2 {
        font-size: 20px;
    }
    h3 {
        font-size: 18px;
    }
    #cnblogs_post_body,
    .cnblogs-post-body,
    .cnblogs-markdown {
        iframe {
            height: 50vw;
        }
    }
}
